namespace Repositories.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class updateContract : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.SpecialCapital", "Special_ID", "dbo.Special");
            DropForeignKey("dbo.ContractInfo", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.ContractInfo", "SellerSupplierId", "dbo.SellerSupplier");
            DropForeignKey("dbo.ContractInfo", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.ContractInfo", "ID", "dbo.Contract");
            DropIndex("dbo.SpecialCapital", new[] { "Special_ID" });
            DropIndex("dbo.ContractInfo", new[] { "ID" });
            DropIndex("dbo.ContractInfo", new[] { "BranchId" });
            DropIndex("dbo.ContractInfo", new[] { "SpecialId" });
            DropIndex("dbo.ContractInfo", new[] { "SellerSupplierId" });
            AddColumn("dbo.Contract", "BranchId", c => c.Int());
            AddColumn("dbo.Contract", "SpecialId", c => c.Int());
            AddColumn("dbo.Contract", "SellerSupplierId", c => c.Int());
            CreateIndex("dbo.Contract", "BranchId");
            CreateIndex("dbo.Contract", "SpecialId");
            CreateIndex("dbo.Contract", "SellerSupplierId");
            AddForeignKey("dbo.Contract", "BranchId", "dbo.Branch", "ID");
            AddForeignKey("dbo.Contract", "SellerSupplierId", "dbo.SellerSupplier", "ID");
            AddForeignKey("dbo.Contract", "SpecialId", "dbo.Special", "ID");
            DropColumn("dbo.SpecialCapital", "Special_ID");
            DropTable("dbo.ContractInfo");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.ContractInfo",
                c => new
                    {
                        ID = c.Int(nullable: false),
                        BranchId = c.Int(),
                        SpecialId = c.Int(),
                        SellerSupplierId = c.Int(),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID);
            
            AddColumn("dbo.SpecialCapital", "Special_ID", c => c.Int());
            DropForeignKey("dbo.Contract", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.Contract", "SellerSupplierId", "dbo.SellerSupplier");
            DropForeignKey("dbo.Contract", "BranchId", "dbo.Branch");
            DropIndex("dbo.Contract", new[] { "SellerSupplierId" });
            DropIndex("dbo.Contract", new[] { "SpecialId" });
            DropIndex("dbo.Contract", new[] { "BranchId" });
            DropColumn("dbo.Contract", "SellerSupplierId");
            DropColumn("dbo.Contract", "SpecialId");
            DropColumn("dbo.Contract", "BranchId");
            CreateIndex("dbo.ContractInfo", "SellerSupplierId");
            CreateIndex("dbo.ContractInfo", "SpecialId");
            CreateIndex("dbo.ContractInfo", "BranchId");
            CreateIndex("dbo.ContractInfo", "ID");
            CreateIndex("dbo.SpecialCapital", "Special_ID");
            AddForeignKey("dbo.ContractInfo", "ID", "dbo.Contract", "ID");
            AddForeignKey("dbo.ContractInfo", "SpecialId", "dbo.Special", "ID");
            AddForeignKey("dbo.ContractInfo", "SellerSupplierId", "dbo.SellerSupplier", "ID");
            AddForeignKey("dbo.ContractInfo", "BranchId", "dbo.Branch", "ID");
            AddForeignKey("dbo.SpecialCapital", "Special_ID", "dbo.Special", "ID");
        }
    }
}
